/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clueless;

/**
 *
 * @author dcain
 */
public class SuggAlertDialog extends javax.swing.JFrame {

    /**
     * Creates new form SuggAlertDialog
     */
    
    
    public SuggAlertDialog() {
        initComponents();
    }
    
    public SuggAlertDialog(String playerSugg,  String[] suggestion, String[] refute) {
        initComponents();        
        textLabel.setText(playerSugg + " has made a suggestion!");
        pRadio.setText(suggestion[0]);
        wRadio.setText(suggestion[1]);
        rRadio.setText(suggestion[2]);
        
        //String[] refute = refutable.split(" ");            
        
        System.out.println("ref 0" + refute[0]);
        System.out.println("ref 1" + refute[1]);
        System.out.println("ref 2" + refute[2]);
        pRadio.setEnabled(Boolean.valueOf(refute[0]));
        wRadio.setEnabled(Boolean.valueOf(refute[1]));    
        rRadio.setEnabled(Boolean.valueOf(refute[2]));
        if(pRadio.isEnabled()){
            pRadio.setSelected(true);
        } else if (wRadio.isEnabled()){
            wRadio.setSelected(true);
        } else {
            rRadio.setSelected(true);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        textLabel = new javax.swing.JLabel();
        pRadio = new javax.swing.JRadioButton();
        wRadio = new javax.swing.JRadioButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        rRadio = new javax.swing.JRadioButton();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        textLabel.setText("Player 1 has made a Suggestion!");

        pRadio.setText("Miss Scarlet");
        pRadio.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                pRadioPropertyChange(evt);
            }
        });

        wRadio.setText("Pipe");

        jLabel2.setText("with the");

        jLabel3.setText("in the");

        rRadio.setText("Study");

        jButton1.setText("Refute!");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pRadio)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(26, 26, 26)
                        .addComponent(wRadio)))
                .addGap(28, 28, 28)
                .addComponent(jLabel3)
                .addGap(38, 38, 38)
                .addComponent(rRadio)
                .addContainerGap(23, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(textLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(50, 50, 50))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(textLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pRadio)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(wRadio)
                    .addComponent(rRadio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(43, 43, 43))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void pRadioPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_pRadioPropertyChange
        // TODO add your handling code here:
    }//GEN-LAST:event_pRadioPropertyChange

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        String message = "";
        if(pRadio.isSelected()){
            message += "p";
        } else if (wRadio.isSelected()){
            message += "w";
        } else if (rRadio.isSelected()){
            message += "r";
        }
        System.out.println("outmessage" + message);
        Clueless.out.println(message);
        dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(SuggAlertDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(SuggAlertDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(SuggAlertDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(SuggAlertDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new SuggAlertDialog().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JRadioButton pRadio;
    private javax.swing.JRadioButton rRadio;
    private javax.swing.JLabel textLabel;
    private javax.swing.JRadioButton wRadio;
    // End of variables declaration//GEN-END:variables
}
